import pymysql as mysql

user_name = input("name>>>>>:").strip()
user_password = input("password>>>>>:").strip()

config = {
    'host': '127.0.0.1',
    'port': 3306,
    'user': 'root',
    'passwd': '123456',
    'db': 'py01db',
    'charset': 'utf8'
}


connection = mysql.connect(**config)
cursor = connection.cursor()

sql_string = "select * from p02user where u_name='%s' and u_pwd='%s'"% (user_name,user_password)
print(sql_string)

rows = cursor.execute(sql_string)

cursor.close()
connection.close()
if rows:
    print('登录成功')
else:
    print('登录失败')
''' 注入写法时的无验证登录
name>>>>>:' or 1=1 -- 1121'
password>>>>>:
select * from p02user where u_name='' or 1=1 -- 1121'' and u_pwd=''
登录成功
'''